package com.study.controller.PSIcontroller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.study.model.mdao.PSImdao.PurchaseDetailMapper;

@RestController
public class PurchaseDetailController {
	@Autowired
	PurchaseDetailMapper pdmapper;
	
	/**
	 * 根据订单编号查询订单详情
	 * @param purorderid
	 * @return
	 */
	@RequestMapping("/selectPurdetailById")
	public String selectPurdetailById(String param) {
		System.out.println("查看订单详情了");
		System.out.println("订单的编号"+param);
		return JSON.toJSONString(pdmapper.findByPurorderid(param));	
	}
	
	@RequestMapping("/updateNumAndDis")
	public void updateNumAndDis(int id,double num,double dis) {
		System.out.println("id为："+id+"\n数量："+num+"\n折扣："+dis);
		Map map=new HashMap();
		map.put("goodsdiscount", dis);
		map.put("goodsnum", num);
		map.put("purdetailid", id);
		pdmapper.updateNumAndDiscount(map);
	}
}
